window.onload = function() {
	var client_2 = document.getElementById("client_2");
	var dialog_border_2 = document.getElementById("dialog_border_2");
	var navHeadimg = document.getElementsByClassName("navHeadimg")[0]
	var navAfterLoginBox = document.getElementsByClassName("navAfterLoginBox")[0]
	client_2.onmouseover = function() {
		dialog_border_2.style.display = "inline-block";
	};
	client_2.onmouseout = function() {
		dialog_border_2.style.display = "none";
	};
	dialog_border_2.onmouseover = function() {
		dialog_border_2.style.display = "inline-block";
	};
	dialog_border_2.onmouseout = function() {
		dialog_border_2.style.display = "none";
	};
	navHeadimg.onmouseover = function() {
		navAfterLoginBox.style.display = "inline-block";
	};
	navHeadimg.onmouseout = function() {
		navAfterLoginBox.style.display = "none";
	};
	navAfterLoginBox.onmouseover = function() {
		navAfterLoginBox.style.display = "inline-block";
	};
	navAfterLoginBox.onmouseout = function() {
		navAfterLoginBox.style.display = "none";
	};
	course_Id = GetUrlByParamName("courseId")
	getCourseDetailByCourseId(course_Id)
	getCookie()
	getAndUpdataMyCourseSchedule()
	getCourseComment()
}

var pageNum = 1
var start
var end
var totalPage
var courseName

function playVideo(a) {
	var thisVideo = videoPath.get(a)
	var video = document.getElementById("video")
	video.src = thisVideo
	courseBodyId = a
	continueVideoPath = thisVideo
	resetCourseBodyTime()
	chapterName = courseBodyName.get(a)
	setContinueStudy()
}

function stopVideo() {
	var video = document.getElementById("video")
	video.pause()
	resetCourseBodyTime()
	setContinueStudy()
}

function continueVideo() {
	var video = document.getElementById("video")
	video.play()
}
var user_token
var user_id
var course_Id
var questionCourseId
var questionCourseBodyId
var courseDetail
var videoPath = new Map()
var dataPath = new Map()
var courseBodyName = new Map()
var courseBodyId
var courseBodyTime
var chapterName
var continueVideoPath

function insideRorate(a) {
	var icon = document.getElementsByClassName("inside")
	for(var i = 0; i < icon.length; i++) {
		turnDown(icon[i]);
	}
	var icon = a.parentElement.children[0]
	var div = a.parentElement.parentElement.parentElement.children[1]
	if((div.classList.contains('collapse')) && !(div.classList.contains("in"))) {
		turnUp(icon)
	} else {
		turnDown(icon)
	}
}

function rorate(a) {
	var icon = document.getElementsByClassName("glyphicon")
	for(var i = 0; i < icon.length; i++) {
		turnDown(icon[i]);
	}
	var icon = a.parentElement.children[0]
	var div = a.parentElement.parentElement.parentElement.children[1]
	if((div.classList.contains('collapse')) && !(div.classList.contains("in"))) {
		turnUp(icon)
	} else {
		turnDown(icon)
	}
}

function turnUp(icon) {
	icon.classList.remove("rotateZero")
	icon.classList.add("rotateOneHundredEight")
}

function turnDown(icon) {
	icon.classList.remove("rotateOneHundredEight")
	icon.classList.add("rotateZero")
}

//function returnList() {
//	var accordion = document.getElementById("accordion")
//	var videoPart = document.getElementById("videoPart")
//	accordion.classList.remove("f-dn")
//	videoPart.classList.add("f-dn")
//}
//

$(document).ready(function() {
	$('[data-toggle="tooltip"]').tooltip();
});

function switchLoginType(a) {
	var hetaoCode = document.getElementById("hetaoCode")
	var hetaoAccount = document.getElementById("hetaoAccount")
	if(a.parentElement == hetaoAccount) {
		hetaoCode.style.display = "block"
		hetaoAccount.style.display = "none"
	} else if(a.parentElement == hetaoCode) {
		hetaoCode.style.display = "none"
		hetaoAccount.style.display = "block"
	}
}

function GetUrlByParamName(name)   {    
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");    
	var URL =  decodeURI(window.location.search);    
	var r = URL.substr(1).match(reg);    
	if(r != null) {       //decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码
		return  decodeURI(r[2]);    
	};    
	return null;  
}

function quit() {
	window.event.returnValue = false
	$.cookie('login_cookie', "", {
		expires: -1,
		path: '/',
	})
	window.location.href = "http://localhost/page/LoginPage/Login.html";
}

function login() {
	var mobile = document.getElementById("inputCount").value
	var password = document.getElementById("inputPassword").value
	var data = {
		"mobile": mobile,
		"password": password,
	}
	$.ajax({
		type: "post",
		url: "http://localhost/zte-api/api/login",
		contentType: "application/json",
		data: JSON.stringify(data),
		success: function(r) {
			console.log(r)
			if(r.msg != "登录成功") {
				alert(r.msg)
			} else {
				$.cookie('login_cookie', r.data.token.token, {
					expires: 123456789,
					path: '/',
				})
				console.log($.cookie("login_cookie"))
				user_token = r.data.token.token
				queryPersonalMessage(r.data.token.token);
			}
		},
		error: function() {
			alert("error");
		}
	});
}

function getCookie() {
	var loginBoolean = $.cookie('login_cookie');
	if(loginBoolean) {
		//JSON.parse()  将字符串解析为对象，方便使用
		user_token = loginBoolean
		document.getElementById("gotoPersonal").href = "http://localhost/page/personalPage/personalPage.html?token=" + user_token
		queryPersonalMessage(user_token);
	} else {
		window.location.href = "http://localhost/page/LoginPage/Login.html"
	}
}

function queryPersonalMessage(a) {
	var data = {
		"token": a,
	}
	$.ajax({
		type: "POST",
		url: "http://localhost/zte-api/api/personal/getUserAndCount?token=" + a,
		contentType: "application/json",
		data: JSON.stringify(data),
		success: function(r) {
			user_id = r.data.userId
			document.getElementById("my-img").src = r.data.headImg
		},
		error: function() {
			alert("error");
		}
	});
}

function getCourseDetailByCourseId(courseId) {
	$.ajax({
		type: "get",
		url: "http://localhost/zte-api/api/course/pcGetCourseById?courseId=" + courseId,
		contentType: "application/json",
		success: function(r) {
			courseDetail = r.data
			console.log(courseDetail)
			setCourseMessage()
		},
		error: function() {
			alert("error");
		}
	});
}

function setCourseMessage() {
	var courseTitle = document.getElementById("courseTitle")
	var talkTeacher = document.getElementById("talkTeacher")
	courseName = courseDetail.title
	courseTitle.innerText = courseDetail.title
	talkTeacher.innerText = courseDetail.teacherName
	createCourseList()
}

function gotoData(a) {
	window.open(dataPath.get(a))
}

function returnTest() {
	var listGroupItem = document.getElementsByClassName("list-group-item")
	for(var i = 0; i < listGroupItem.length; i++) {
		listGroupItem[i].classList.remove("active")
	}
}

function createCourseList() {
	var str = ""
	for(var i = 0; i < courseDetail.childBody.length; i++) {
		str += '<div class="panel panel-primary">'
		str += '<div class="panel-heading">'
		str += '<h4 class="panel-title">'
		str += '<span class="glyphicon glyphicon-chevron-down rotateZero"></span>'
		str += '<a data-toggle="collapse" data-parent="#accordion" href="#' + courseDetail.childBody[i].id + '" onclick="rorate(this)">'
		str += courseDetail.childBody[i].chapterName
		str += '</a>'
		if(courseDetail.childBody[i].questionTotal != 0) {
			str += '<span onclick="gotoQuestion(' + courseDetail.childBody[i].courseId + ',' + courseDetail.childBody[i].id + ')" href="#homework" aria-controls="homework" role="tab" data-toggle="tab" class="fa fa-pencil-square-o iconOpiton" style="color:white;" title="题目"></span>'
		}
		str += '</h4>'
		str += '</div>'
		str += '<div id="' + courseDetail.childBody[i].id + '" class="panel-collapse collapse">'
		str += '<div class="panel-body">'
		str += '<ul class="list-group">'
		if(courseDetail.childBody[i].childBody != null || courseDetail.childBody[i].childBody != undefined) {
			for(var fo = 0; fo < courseDetail.childBody[i].childBody.length; fo++) {
				if(courseDetail.childBody[i].childBody[fo].childBody != undefined) {
					str += '<div class="panel-group" id="forInside' + courseDetail.childBody[i].id + '">'
					break;
				}
			}
			for(var f = 0; f < courseDetail.childBody[i].childBody.length; f++) {
				if(courseDetail.childBody[i].childBody[f].childBody != null) {
					str += '<div class="panel panel-default">'
					str += '<div class="panel-heading">'
					str += '<h4 class="panel-title"><span class="glyphicon glyphicon-chevron-down rotateZero inside"></span>'
					str += '<a data-toggle="collapse" data-parent="#forInside' + courseDetail.childBody[i].id + '" href="#' + courseDetail.childBody[i].childBody[f].id + '" onclick="insideRorate(this)" class="collapsed" aria-expanded="false">' + courseDetail.childBody[i].childBody[f].chapterName + '</a>'
					if(courseDetail.childBody[i].childBody[f].questionTotal != 0) {
						str += '<span onclick="gotoQuestion(' + courseDetail.childBody[i].childBody[f].courseId + ',' + courseDetail.childBody[i].childBody[f].id + ')" href="#homework" aria-controls="homework" role="tab" data-toggle="tab" class="fa fa-pencil-square-o iconOpiton" title="题目"></span>'
					}
					str += '</h4>'
					str += '</div>'
					str += '<div id="' + courseDetail.childBody[i].childBody[f].id + '" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">'
					str += '<div class="panel-body">'
					str += '<ul class="list-group">'
					for(var t = 0; t < courseDetail.childBody[i].childBody[f].childBody.length; t++) {
						str += '<li class="list-group-item">'
						if(courseDetail.childBody[i].childBody[f].childBody[t].questionTotal != 0) {
							str += '<span onclick="gotoQuestion(' + courseDetail.childBody[i].childBody[f].childBody[t].courseId + ',' + courseDetail.childBody[i].childBody[f].childBody[t].id + ')" href="#homework" aria-controls="homework" role="tab" data-toggle="tab" class="fa fa-pencil-square-o iconOpiton" title="题目"></span>'
						}
						if(courseDetail.childBody[i].childBody[f].childBody[t].dataType != null) {
							dataPath.set(courseDetail.childBody[i].childBody[f].childBody[t].id, courseDetail.childBody[i].childBody[f].childBody[t].dataPath)
							str += '<span class="glyphicon glyphicon-list-alt iconOpiton" title="查看文档" onclick="gotoData(' + courseDetail.childBody[i].childBody[f].childBody[t].id + ')"> </span>'
						} else {
							//str += '<span class="glyphicon glyphicon-list-alt iconOpiton" title="无文档"> </span>'
						}
						if(courseDetail.childBody[i].childBody[f].childBody[t].videoPath != null) {
							videoPath.set(courseDetail.childBody[i].childBody[f].childBody[t].id, courseDetail.childBody[i].childBody[f].childBody[t].videoPath)
							str += '<span class="glyphicon glyphicon-play-circle iconOpiton" title="播放视频" onclick="playVideo(' + courseDetail.childBody[i].childBody[f].childBody[t].id + ')"> </span>'
							str += '<span onclick="playVideo(' + courseDetail.childBody[i].childBody[f].childBody[t].id + ')">' + courseDetail.childBody[i].childBody[f].childBody[t].chapterName + '</span>'
							var name = courseDetail.childBody[i].childBody[f].chapterName + courseDetail.childBody[i].childBody[f].childBody[t].chapterName
							courseBodyName.set(courseDetail.childBody[i].childBody[f].childBody[t].id, name)
						} else {
							//str += '<span class="glyphicon glyphicon-play-circle iconOpiton" title="无视频"> </span>'
							str += '<span title="无视频">' + courseDetail.childBody[i].childBody[f].childBody[t].chapterName + '</span>'
						}
						str += '</li>'
					}
					for(var fo = 0; fo < courseDetail.childBody[i].childBody.length; fo++) {
						if(courseDetail.childBody[i].childBody[fo].childBody != undefined) {
							str += '<div class="panel-group" id="accordion">'
							break;
						}
					}
					str += '</ul>'
					str += '</div>'
					str += '</div>'
					str += '</div>'
				} else {
					str += '<li class="list-group-item" style="background-color:white;color:black;border:1px solid rgba(0,0,0,0.12);">'
					if(courseDetail.childBody[i].childBody[f].questionTotal != 0) {
						str += '<span onclick="gotoQuestion(' + courseDetail.childBody[i].childBody[f].courseId + ',' + courseDetail.childBody[i].childBody[f].id + ')" href="#homework" aria-controls="homework" role="tab" data-toggle="tab" class="fa fa-pencil-square-o iconOpiton" title="题目"></span>'
					}
					if(courseDetail.childBody[i].childBody[f].dataType != null) {
						dataPath.set(courseDetail.childBody[i].childBody[f].id, courseDetail.childBody[i].childBody[f].dataPath)
						str += '<span class="glyphicon glyphicon-list-alt iconOpiton" title="查看文档" onclick="gotoData(' + courseDetail.childBody[i].childBody[f].id + ')"> </span>'
					} else {
						//str += '<span class="glyphicon glyphicon-list-alt iconOpiton" title="无文档"> </span>'
					}
					if((courseDetail.childBody[i].childBody[f].videoPath != null) || (courseDetail.childBody[i].childBody[f].videoHdPath != null)) {
						if(courseDetail.childBody[i].childBody[f].videoHdPath != null) {
							videoPath.set(courseDetail.childBody[i].childBody[f].id, courseDetail.childBody[i].childBody[f].videoHdPath)
						} else {
							videoPath.set(courseDetail.childBody[i].childBody[f].id, courseDetail.childBody[i].childBody[f].videoPath)
						}
						str += '<span class="glyphicon glyphicon-play-circle iconOpiton" title="播放视频" onclick="playVideo(' + courseDetail.childBody[i].childBody[f].id + ')"> </span>'
						str += '<span onclick="playVideo(' + courseDetail.childBody[i].childBody[f].id + ')">' + courseDetail.childBody[i].childBody[f].chapterName + '</span>'
						courseBodyName.set(courseDetail.childBody[i].childBody[f].id, courseDetail.childBody[i].childBody[f].chapterName)
					} else {
						//						str += '<span class="glyphicon glyphicon-play-circle iconOpiton" title="无视频"> </span>'
						str += '<span title="无视频">' + courseDetail.childBody[i].childBody[f].chapterName + '</span>'
					}
					str += '</li>'
				}
			}

		}
		str += '</ul>'
		str += '</div>'
		str += '</div>'
		str += '</div>'
	}
	document.getElementById("accordion").innerHTML = str
}

function gotoQuestion(courseId, courseBodyId) {
	questionCourseId = courseId
	questionCourseBodyId = courseBodyId
	var data = {
		"courseId": courseId,
		"courseBodyId": courseBodyId,
	}
	$.ajax({
		type: "post",
		url: "http://localhost/zte-api/api/courseTest/getAllCourseTest?token=" + user_token,
		contentType: "application/json",
		data: JSON.stringify(data),
		success: function(r) {
			console.log(r.data)
			setQuestion(r.data)
		},
		error: function() {
			alert("error");
		}
	});
}

function setQuestion(question) {
	var questionBox = document.getElementById("questionBox")
	var str = ""
	for(var i = 0; i < question.length; i++) {
		if(question[i].questionTypeId == 0) {
			str += '<li style="margin-top: 10px;">'
			str += '<span>' + question[i].questionContent + '</span>'
			if((question[i].questonContentImg != null) || (question[i].questonContentImg != undefined)) {
				if(question[i].questonContentImg != '') {
					str += '<img height=50 width=150 src="' + question[i].questonContentImg + '"/>'
				}
			}
			str += '<div class="answer">'
			str += '<div>'
			str += '<label class="radio-inline">'
			str += '<input type="radio" name="' + i + '" value="A"> ' + question[i].questionOptions[0].option + ''
			if((question[i].questionOptions[0].img != null) || (question[i].questionOptions[0].img != undefined)) {
				if(question[i].questionOptions[0].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[0].img + '"/>'
				}
			}
			str += '</label>'
			str += '</div>'
			str += '<div>'
			str += '<label class="radio-inline">'
			str += '<input type="radio" name="' + i + '" value="B"> ' + question[i].questionOptions[1].option + ''
			if((question[i].questionOptions[1].img != null) || (question[i].questionOptions[1].img != undefined)) {
				if(question[i].questionOptions[1].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[1].img + '"/>'
				}
			}
			str += '</label>'
			str += '</div>'
			str += '</div>'
			str += '</li>'
		} else if(question[i].questionTypeId == 1) {
			str += '<li style="margin-top: 10px;">'
			str += '<span>' + question[i].questionContent + '</span>'
			if((question[i].questonContentImg != null) || (question[i].questonContentImg != undefined)) {
				if(question[i].questonContentImg != '') {
					str += '<img height=50 width=150 src="' + question[i].questonContentImg + '"/>'
				}
			}
			str += '<div class="answer">'
			str += '<label class="radio-inline">'
			str += '<input type="radio" name="' + i + '" value="A"> ' + question[i].questionOptions[0].option + ''
			if((question[i].questionOptions[0].img != null) || (question[i].questionOptions[0].img != undefined)) {
				if(question[i].questionOptions[0].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[0].img + '"/>'
				}
			}
			str += '</label>'
			str += '<label class="radio-inline">'
			str += '<input type="radio" name="' + i + '" value="B"> ' + question[i].questionOptions[1].option + ''
			if((question[i].questionOptions[1].img != null) || (question[i].questionOptions[1].img != undefined)) {
				if(question[i].questionOptions[1].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[1].img + '"/>'
				}
			}
			str += '</label>'
			str += '<label class="radio-inline">'
			str += '<input type="radio" name="' + i + '" value="C"> ' + question[i].questionOptions[2].option + ''
			if((question[i].questionOptions[2].img != null) || (question[i].questionOptions[2].img != undefined)) {
				if(question[i].questionOptions[2].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[2].img + '"/>'
				}
			}
			str += '</label>'
			str += '<label class="radio-inline">'
			str += '<input type="radio" name="' + i + '" value="D"> ' + question[i].questionOptions[3].option + ''
			if((question[i].questionOptions[3].img != null) || (question[i].questionOptions[3].img != undefined)) {
				if(question[i].questionOptions[3].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[3].img + '"/>'
				}
			}
			str += '</label>'
			str += '</div>'
			str += '</li>'
		} else if(question[i].questionTypeId == 2) {
			str += '<li style="margin-top: 10px;">'
			str += '<span>' + question[i].questionContent + '</span>'
			if((question[i].questonContentImg != null) || (question[i].questonContentImg != undefined)) {
				if(question[i].questonContentImg != '') {
					str += '<img height=50 width=150 src="' + question[i].questonContentImg + '"/>'
				}
			}
			str += '<div class="answer">'
			str += '<label class="radio-inline">'
			str += '<input style="position: absolute;margin-left: -20px;margin-top: 0px;" type="checkbox" name="' + i + '" value="A"> ' + question[i].questionOptions[0].option + ''
			if((question[i].questionOptions[0].img != null) || (question[i].questionOptions[0].img != undefined)) {
				if(question[i].questionOptions[0].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[0].img + '"/>'
				}
			}
			str += '</label>'
			str += '<label class="radio-inline">'
			str += '<input style="position: absolute;margin-left: -20px;margin-top: 0px;" class="questionCheckBox" type="checkbox" name="' + i + '" value="B"> ' + question[i].questionOptions[1].option + ''
			if((question[i].questionOptions[1].img != null) || (question[i].questionOptions[1].img != undefined)) {
				if(question[i].questionOptions[1].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[1].img + '"/>'
				}
			}
			str += '</label>'
			str += '<label class="radio-inline">'
			str += '<input style="position: absolute;margin-left: -20px;margin-top: 0px;" class="questionCheckBox" type="checkbox" name="' + i + '" value="C"> ' + question[i].questionOptions[2].option + ''
			if((question[i].questionOptions[2].img != null) || (question[i].questionOptions[2].img != undefined)) {
				if(question[i].questionOptions[2].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[2].img + '"/>'
				}
			}
			str += '</label>'
			str += '<label class="radio-inline">'
			str += '<input style="position: absolute;margin-left: -20px;margin-top: 0px;" class="questionCheckBox" type="checkbox" name="' + i + '" value="D"> ' + question[i].questionOptions[3].option + ''
			if((question[i].questionOptions[3].img != null) || (question[i].questionOptions[3].img != undefined)) {
				if(question[i].questionOptions[3].img != '') {
					str += '<img height=50 width=150 src="' + question[i].questionOptions[3].img + '"/>'
				}
			}
			str += '</label>'
			str += '</div>'
			str += '</li>'
		}
	}
	questionBox.innerHTML = str
}

function sendAnswer() {
	var question = document.getElementById("questionBox").children
	var answer = new Array()
	for(var i = 0; i < question.length; i++) {
		var thisQuestion = document.getElementsByName(i)
		var forReturnAnswer = ""
		for(var f = 0; f < thisQuestion.length; f++) {
			if(thisQuestion[f].checked == true) {
				forReturnAnswer += thisQuestion[f].value
			}
		}
		answer.push(forReturnAnswer)
	}
	var answerList = '[' + answer.toString() + ']'
	var data = {
		"courseId": questionCourseId,
		"courseBodyId": questionCourseBodyId,
		"token": user_token,
		"answerList": answerList
	}
	$.ajax({
		type: "post",
		url: "http://localhost/zte-api/api/courseTest/checkAnswer?token=" + user_token,
		contentType: "application/json",
		data: JSON.stringify(data),
		success: function(r) {
			console.log(r)
			var answerResult = document.getElementById("answerResult")
			var str = ""
			var allright = 0
			for(var i = 0; i < r.courseTestEntityList.length; i++) {
				if((r.errorIds.indexOf(i + 1)) == -1) {
					allright++
					str += '<p>错误题目:' + r.courseTestEntityList[i].questionContent + '</p>'
					var forOption
					if(r.courseTestEntityList[i].answer == "A") {
						forOption = 0
					} else if(r.courseTestEntityList[i].answer == "B") {
						forOption = 1
					} else if(r.courseTestEntityList[i].answer == "C") {
						forOption = 2
					} else {
						forOption = 3
					}
					str += '<p>正确答案' + r.courseTestEntityList[i].answer + r.courseTestEntityList[i].questionOptions[forOption].option + '</p>'
				}
			}
			if(allright == 0) {
				str += '<p>全对!</p>'
			}
			answerResult.innerHTML = str
		},
		error: function() {
			alert("error");
		}
	});
}

function getAndUpdataMyCourseSchedule() {
	if(courseBodyId == undefined && courseBodyTime == undefined) {
		var data = {
			"courseId": course_Id,
			"courseBodyId": courseBodyId,
			"courseBodyTime": courseBodyTime
		}
		$.ajax({
			type: "post",
			url: "http://localhost/zte-api/api/myCourse/saveMyCourseSchedule?token=" + user_token,
			contentType: "application/json",
			data: JSON.stringify(data),
			success: function(r) {
				console.log(r)
				chapterName = r.courseBody.chapterName
				courseBodyId = r.courseSchedule.courseBodyId
				courseBodyTime = r.courseSchedule.courseBodyTime
				if((r.courseBody.videoPath != null) || (r.courseBody.videoHdPath != null)) {
					if(r.courseBody.videoHdPath != null) {
						continueVideoPath = r.courseBody.videoHdPath
					} else {
						continueVideoPath = r.courseBody.videoPath
					}

				}

				setContinueStudy()
			},
			error: function() {
				alert("error");
			}
		});
	} else {
		var data = {
			"courseId": course_Id,
			"courseBodyId": courseBodyId,
			"courseBodyTime": courseBodyTime
		}
		$.ajax({
			type: "post",
			url: "http://localhost/zte-api/api/myCourse/saveMyCourseSchedule?token=" + user_token,
			contentType: "application/json",
			data: JSON.stringify(data),
			success: function(r) {
				console.log(r)
				//				此种情况只为保存视频进度
			},
			error: function() {
				alert("error");
			}
		});
	}
}

function setContinueStudy() {
	var continueVideoTime = formatDuring(parseInt(courseBodyTime))
	document.getElementById("continue").innerText = chapterName + continueVideoTime
	document.getElementById("video").src = continueVideoPath
	document.getElementById("video").currentTime = parseInt(courseBodyTime / 1000)
	document.getElementById("continueButton").onclick = function() {
		document.getElementById("公告").classList.remove("active")
		document.getElementById("课件").classList.add("active")
		document.getElementById("评论").classList.remove("active")
		document.getElementById("video").play()
	}
}

function formatDuring(mss) {
	var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
	var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
	var seconds = parseInt((mss % (1000 * 60)) / 1000);
	return hours + " : " + minutes + " : " + seconds;
}

function resetCourseBodyTime() {
	var videoTime = document.getElementById("video").currentTime
	var forReturn = parseInt((videoTime * 1000))
	courseBodyTime = forReturn
}

function pageCloseSave() {
	resetCourseBodyTime()
	getAndUpdataMyCourseSchedule()
}

function getCourseComment() {
	var data = {
		"pageNum": pageNum,
		"pageSize": 10,
		"courseId": course_Id
	}
	$.ajax({
		type: "post",
		url: "http://localhost/zte-api/api/course/getCourseCommentByCourseIdPc",
		contentType: "application/json",
		data: JSON.stringify(data),
		success: function(r) {
			console.log(r)
			setCourseComment(r.commentList.list)
			start = r.commentList.start
			end = r.commentList.end
			totalPage = r.commentList.totalPage
			createPageBox()
		},
		error: function() {
			alert("error");
		}
	});
}

function createPageBox() {
	var pagination = document.getElementById("pagination")
	var option = ""
	if(end != 0) {
		option += '<a onclick="changePageBox(1)" class="prev">首页</a>'
		option += '</li>'
		for(var i = start; i <= end; i++) {
			if(i == pageNum) {
				option += '<span class="current p_interval" id="' + i + '">' + i + '</span>'
			} else {
				option += '<a class="p_interval" onclick="changePageBox(this.id)" id="' + i + '">' + i + '</a>'
			}
		}
		option += '<a onclick="changePageBox(' + totalPage + ')" class="prev lastclass">尾页</a>'
		pagination.innerHTML = option
	} else {
		option += '<div style="width: 100%;height: 300px;line-height: 300px;color: #999;font-size: 18px;text-align:center;">'
		option += '<span>当前课程无评论</span>'
		option += '</div>'
		pagination.innerHTML = option
	}

}

function changePageBox(id) {
	pageNum = parseInt(id)
	getCourseComment()
}

function setCourseComment(commentList) {
	//	document.getElementById("review-tag-num").innerText = "（" + commentList.length + ")"
	var str = ""
	for(var i = 0; i < commentList.length; i++) {
		str += '<div class="commentListPart f-cb">'
		str += '<div style="width: 200px;height: 143.8px;display: flex;float: left;text-align: center;flex-direction:column;color: black;">'
		str += '<h5 style="flex: 1;">来自:</h5>'
		str += '<h5 style="flex: 1;">' + courseName + '</h5>'
		str += '<h6 style="flex: 1;">' + commentList[i].createTime + '</h6>'
		str += '</div>'
		str += '<div class="headslider">'
		str += '<a href="' + commentList[i].userId + '" class="media" target="_blank" title="' + commentList[i].userName + '"><img src="' + commentList[i].userHeadImage + '" width="40" height="40"></a>'
		str += '</div>'
		str += '<div class="commentSlider">'
		str += '<div class="tit">'
		str += '<a href="' + commentList[i].userId + '" target="_blank">' + commentList[i].userName + '</a>'
		str += '</div>'
		str += '<div class="cnt">' + commentList[i].content + '</div>'
		str += '<div class="qa-footer f-cb">'
		//		str += '<a href="" style="line-height: 36px;color: white;" onclick="delMyComment(0,73)">删除</a>'	
		str += '</div>'
		str += '</div>'
		str += '</div>'
	}
	document.getElementById("AllcommentList").innerHTML = str
}